let baseTime = 1000
function Restaurant(res){
    this.money = res.money //总共的钱
    this.seatNum = res.seatNum //座位数
    this.staff = res.staff //员工人数
    this.danli = null
    this.menu = [] //饭店的菜单
}
Restaurant.prototype.hire = function(staff){//招聘
   this.staff.push(staff)
}
Restaurant.prototype.fire  = function(staff){//解雇
  for(let i = 0;i< this.staff.length;i++){
    if(staff.id == this.staff[i].id){
      this.staff.splice(i,1)
    }
  }
}
Restaurant.prototype.addMenu = function(arr){
  for(let i = 0;i<arr.length;i++){
    this.menu.push(arr[i])
  }
}
Restaurant.create = function(obj){
  if(!this.danli){
    return this.danli = new Restaurant(obj)
  }
  return this.danli
}

function Staff(id,name,salary){//职员
    // 属性：ID，姓名，工资
    this.id = id;
    this.name = name || "";
    this.salary = salary || "100";
  }
function Waiter(id,name,pay){
  Staff.call(this,id,name,pay)
  this.type = 1 // 服务员类型
  this.w_status = 0  // 0空闲1送菜单2送菜中
  this.position  = 0 // 0服务员位置 1厨师位置
}
Waiter.prototype.tell = function(menu,cooker){//通知做菜
    console.log(menu,cooker)
    cooker.cookList = menu.concat()
    this.w_status = 1
    this.position = 1
}
Waiter.prototype.sendDish = function(){//送菜

}


function Cooker(id,name,pay){
  Staff.call(this,id,name,pay)
  this.cookList = [] //待做菜单
  this.type = 2
  this.c_status = 0 //0空闲1做菜 
} 
Cooker.prototype.cookDish = function(){//做菜
     console.log(this.cookList[0],this.cookList[0].name)
     return new Promise((reslove,reject)=>{
        setTimeout(()=>{
          console.log('厨师做好了' + this.cookList[0].name)
          this.cookList.splice(0,1)
          reslove()
        },baseTime * this.cookList[0].time)
     })
}  

function Visitor(name){
    this.name = name
    this.g_menu = []
    this.g_status = 0
}
Visitor.prototype.pointFood = function(){
  let num = Math.floor(Math.random()*5);
  if(num == 0) num = 1
  this.g_menu = skyPeople.menu.slice(0,num);
}
// 菜品类
function Dishes(name,cost,price,time){
  // 属性：名字、烹饪成本、价格
  this.name = name;
  this.cost = cost;
  this.price = price;
  this.time = time;
  this.cai_status = 0
}